/*
https://leetcode-cn.com/problems/di-string-match/solution/zeng-jian-zi-fu-chuan-pi-pei-by-leetcode/
 */
import java.util.Arrays;

public class Solution942 {
    public int[] diStringMatch(String s) {
        int[] ans=new int[s.length()+1];
        int l=0,r=s.length();
        for (int i=0;i<s.length();i++){
            if (s.charAt(i)=='I'){
                ans[i]=l;
                l++;
            }else{
                ans[i]=r;
                r--;
            }
        }
        ans[s.length()]=l;
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Solution942().diStringMatch("IDID")));
    }
}
